package hacker_rank.mar14;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class SherlockSquares {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int T = Integer.parseInt(br.readLine());
		
		for(int t = 0; t < T; t++) {
			String[] line = br.readLine().split(" ");
			int A = Integer.parseInt(line[0]);
			int B = Integer.parseInt(line[1]);
			
			solve(A,B);
		}
	}
	
	static void solve(int a, int b)
	{
		int res = 0;
		
		for(int n = 1; ; n++) {
			if(n * n < a)
				continue;
			if(n * n > b)
				break;
			res++;
		}
		System.out.println(res);

		
	}

}
